var url =window.location.href;
var qrcode = new QRCode('qrcode',{
  //二维码内容
  text: "https://www.lichenes.cn/",
  colorDark : '#000000',
  //二维码背景色
  colorLight : "#fff",
  correctLevel : QRCode.CorrectLevel.H,
  //二维码中心图片
  iconSrc: "/img/timg.jpg",
  //二维码中心图片边框弧度
  iconRadius: 10,
  //二维码中心图片边框宽度
  iconBorderWidth: 0,
  //二维码中心图片边框颜色
  iconBorderColor: "red",
});

function share(phone) {
  var q = qrcode.clear(); // clear the code.
  var path = url.split("/");
  var realPath = "";
  for (var i = 0; i < 3; i++) {
    realPath += path[i] + "/";
  }
  realPath += "singleShop/"+phone;
  qrcode.makeCode(realPath);
}
function collect(pid) {
  $.ajax({
    url: "/collect",
    type: "post",
    data: {
      pid: pid
    },
    dataType: "json",
    success: function (result) {
      if (result) {
        showMsg('添加收藏夹成功！', 'top', 'successful');
      } else {
        showMsg('账号没登录，请登录！', 'top', 'error');
      }
    },
    error: function (result) {
      console.log(0)
    }
  });
}

function indent(pid) {
  $.ajax({
    url: "/indent",
    type: "post",
    data: {
      pid: pid
    },
    dataType: "json",
    success: function (result) {
      if (result) {
        showMsg('添加收藏夹成功！', 'top', 'successful');
      } else {
        showMsg('账号没登录，请登录！', 'top', 'error');
      }
    },
    error: function (result) {
      console.log(0)
    }
  });
}